{include file="public/header" /}
<style type="text/css">.gray-bg {
    background: #fff;
}

.wrapper {
    padding: 0px;
}</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <form class="form-horizontal" method="post">
            <div class="col-sm-12">
                <div class="ibox-content">
                    <input type="hidden" name="id" value="{$data['id']}" />

                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务名称：</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" id="name" name="name"
                                   value="{$data.name|default=''}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">类名：</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" id="class_name" name="class_name"
                                   value="{$data.class_name|default=''}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">方法名：</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" id="function_name" name="function_name"
                                   value="{$data.function_name|default=''}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">执行周期：</label>
                        <div class="col-sm-9">
                            <select id="type" name="type" class="form-control">
                                {foreach $types as $key => $item}
                                <option value="{$key}" {if $data.type eq $key}selected="selected"{/if}>{$item}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>



                    <div class="form-group cycle">
                        <label class="col-sm-2 control-label" id="cycle_title">时间：</label>
                        <div class="col-sm-9">
                            <input class="form-control date_type" type="text" id="cycle_0" name="cycle_0"
                                   readonly="readonly"
                                   value="{$data.cycle|date='Y-m-d H:i'|default=''}" placeholder="yyyy-MM-dd HH:mm"/>

                            <input class="form-control date_type" type="text" id="cycle_1" name="cycle_1" style="display: none;"
                                   value="{$cycle|default=''}"/>
                            <input class="form-control date_type" type="text" id="cycle_2" name="cycle_2" style="display: none;"
                                   value="{$cycle|default=''}"/>
                            <input class="form-control date_type" type="text" id="cycle_3" name="cycle_3" style="display: none;"
                                   value="{$cycle|default=''}"/>
                            <input class="form-control date_type" type="text" id="cycle_4" name="cycle_4" style="display: none;"
                                   value="{$cycle|default=''}"/>
                            <input class="form-control date_type" type="text" id="cycle_5" name="cycle_5" style="display: none;"
                                   value="{$cycle|default=''}"/>
                            <select class="form-control date_type" id="cycle_6" name="cycle_6" style="display: none;">
                                {foreach $weekarray as $k=>$v}
                                <option value="{$k}" {if $cycle eq $k}selected="selected"{/if}>{$v}</option>
                                {/foreach}

                            </select>
                            <input class="form-control date_type" type="text" id="cycle_7" name="cycle_7" style="display: none;"
                                   value="{$cycle|default=''}"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否启用：</label>
                        <div class="col-sm-9">
                            <div class="radio i-checks">
                                <label>
                                    <input type="radio" name="state" value="1" {if !isset($data.state) or $data.state eq 1}checked="checked"{/if} /> 启用
                                </label>
                                <label>
                                    <input type="radio" name="state" value="0" {if isset($data.state) and $data.state eq 0}checked="checked"{/if} /> 禁用
                                </label>
                            </div>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务开始时间：</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" id="begin_time" name="begin_time"
                                   readonly="readonly"
                                   value="{$data.begin_time|date='Y-m-d H:i'|default=''}" placeholder="yyyy-MM-dd HH:mm"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">任务结束时间：</label>
                        <div class="col-sm-9">
                            <input class="form-control" type="text" id="end_time" name="end_time"
                                   readonly="readonly"
                                   value="{$data.end_time|date='Y-m-d H:i'|default=''}" placeholder="yyyy-MM-dd HH:mm"/>
                        </div>
                    </div>




                </div>
            </div>
            <input type="hidden" name="id" value="{$data.id|default=0}"/>
        </form>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="__STYLE__/admin/js/area.js?ver=20200522"></script>
{load href="__STYLE__/admin/plugins/iCheck/icheck.min.js"}
{load href="__STYLE__/admin/plugins/iCheck/custom.css"}
<script type="text/javascript">
    $(document).ready(function () {
        $(".i-checks").iCheck({
            checkboxClass: "icheckbox_square-green",
            radioClass: "iradio_square-green",
        });
    });


    layui.use('laydate', function () {

        layui.laydate.render({ //任务开始时间
            elem: '#begin_time'
            , type: 'datetime'
            , format: 'yyyy-MM-dd HH:mm'
        });
        layui.laydate.render({ //任务结束时间
            elem: '#end_time'
            , type: 'datetime'
            , format: 'yyyy-MM-dd HH:mm'
        });



        //时间选择器
        layui.laydate.render({ //单次
            elem: '#cycle_0'
            , type: 'datetime'
            , format: 'yyyy-MM-dd HH:mm'
        });

    });

    $("#upload").click(function () {
        layer.open({
            type: 2,
            title: '上传图片',
            shadeClose: true,
            shade: 0.2,
            area: ['70%', '60%'],
            skin: 'shangchuantup',
            content: "{:url('common/upload', ['type' => 'avatar'])}",
            shift: -1,
            scrollbar: false,
            moveType: 1,
            moveOut: true
        });
    });
    change();
    $("#type").change(function () {
        change();
    });

    function change() {
        $(".date_type").hide();
        var choose_val = parseInt($("#type").val());
        $("#cycle_" + choose_val).show();

        var cycle_title=$("#type option:selected").text().substring(1) + "：";
        if(choose_val==0){
            cycle_title='时间：';
        }else if(choose_val==3){
            cycle_title='分：';
        }
        $("#cycle_title").text(cycle_title);
        if($.inArray(choose_val,[1,3,7])!=-1){
            $(".cycle").hide();
        }else{
            $(".cycle").show();
        }
    }



</script>
{include file="public/bottom" /}